home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / DSMODS / TWDRAW.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-10  |  15.3 KB  |  732 lines

  1. /*
  2.     This module keeps the Text Window up-to-date
  3. */
  4. #include    "gemdefs.h"
  5. #include    <obdefs.h>
  6. #include    "defs.h"
  7.  
  8. extern    int        txt_handle;        /* TWindow    handle    */
  9. extern    int        shandle;        /* System VDI    handle    */
  10. extern    GRECT        twork;            /* TWindow work area    */
  11. extern    GRECT        full;            /* Full-size of window    */
  12. extern    int        gl_hchar;        /* Text char height    */
  13. extern    int        msg_buff[];        /* evnt_multi buffer    */
  14. extern    char        *TWmesg[];        /* TWindow default Mesg    */
  15. extern    int        TWVSLpos;        /* TW VSlider position    */
  16. extern    int        TWVSLsize;        /* TW VSlider size    */
  17. extern    int        mrkfctN;        /* current Mark functN    */
  18. extern    unsigned char    ctvdc(), *malloc(), nuls[];
  19.  
  20. static    char        wwon;            /* local word wrap flag    */
  21. static    char        lrow;            /* local text row    */
  22. static    char        lcol;            /* local text column    */
  23. static    unsigned char    TWLnbuf[80];        /* TWindow Line buffer    */
  24. static    unsigned char    TWNmbuf[80];        /* TWindow Name buffer    */
  25. static    unsigned char    TWIfbuf[80];        /* TWindow Info buffer    */
  26. static    int        VSchk;            /* Vert. slider check    */
  27. static    unsigned char    *(*scanline)();        /* Scan line test fctN    */
  28. static    int        (*attrtest)();        /* Attribute test fctN    */
  29. static    int        cur_atr;        /* cur. text attribute    */
  30. static    int        cMrk;            /* cur. text marker    */
  31.     int        TWrfmod;        /* TWindow refresh mode    */
  32.     int        TWhclip;        /* TWindow horiz. clip    */
  33.  
  34. /*
  35.     Function to initialize Text Window text positions
  36. */
  37. init_Tpos()
  38. {
  39.     int    dummy;
  40.  
  41.     current.row = top_row, current.col = 0;
  42.     TWrfmod = 3, TWhclip = 0;
  43.     vst_alignment(shandle,0,5,&dummy,&dummy);
  44.     setupcurs();
  45.     setupGreek();
  46. }
  47.  
  48. /*
  49.     Function to get the number of rows of a full size window to
  50.     setup Text Window tag array
  51. */
  52. set_TWrows()
  53. {
  54.     unsigned TWH, dummy;
  55.  
  56.     wind_set(txt_handle,WF_CURRXYWH,full.g_x,full.g_y,full.g_w,full.g_h);
  57.     wind_get(txt_handle,WF_WORKXYWH,&dummy,&dummy,&dummy,&TWH);
  58.     wdw_rows = TWH / gl_hchar;
  59.     wdw_tags = top_line + wdw_rows;
  60.     wdw_ptr = (char **)malloc(4 * wdw_tags);
  61. }
  62.  
  63. cur_line()
  64. {
  65.     return(top_line + current.row);
  66. }
  67.  
  68. bot_line()
  69. {
  70.     return(top_line + current.mrow - 1);
  71. }
  72.  
  73. unsigned char    *skiptag(ptr)
  74. unsigned char    *ptr;
  75. {
  76.     if (tagc(*ptr))
  77.         ptr += 2;
  78.     else    ++ptr;
  79.     return(ptr);                /* returns new pointer    */
  80. }
  81.  
  82. unsigned char    *toeofline(ptr)
  83. unsigned char    *ptr;
  84. {
  85.     while (ptr < buf_end && *ptr != lf)
  86.         ptr = skiptag(ptr);
  87.     return(ptr);                /* ptr to end line lf    */
  88. }
  89.  
  90. unsigned char    *out_line(ptr)
  91. unsigned char    *ptr;
  92. {
  93.     unsigned char    *tptr, scol;
  94.     int        new_atr;
  95.  
  96.     tptr    = TWLnbuf;
  97.     scol    = lcol;
  98.     while (ptr < buf_end && *ptr != cr) {
  99.         if (lcol >= TWhclip) {
  100.             new_atr = (*attrtest)(ptr);
  101.             if (new_atr != cur_atr) {
  102.                 if (*TWLnbuf) {
  103.                     *tptr    = 0;
  104.                     wdw_line(lrow,TWcol(scol));
  105.                     tptr    = TWLnbuf;
  106.                     scol    = lcol;
  107.                 }
  108.                 vst_effects(shandle,cur_atr = new_atr);
  109.             }
  110.             *tptr++ = ctvdc(*ptr);
  111.         }
  112.         ptr = skiptag(ptr);
  113.         ++lcol;
  114.     }
  115.     if (*ptr == cr) ++ptr;
  116.     *tptr    = 0;
  117.     wdw_line(lrow,TWcol(scol));
  118.     return(ptr);                /* ptr to end line lf    */
  119. }
  120.  
  121. unsigned char    *next_line(ptr)
  122. unsigned char    *ptr;
  123. {
  124.     wdw_ptr[TMP4] = buf_end;
  125.     word_wrap(ptr,lcol,1);            /* word wrap one line    */
  126.     TWrewindow(wdw_ptr[WWRP]);        /* back to start point    */
  127.     ptr = out_line(current_char);        /* send to Window line    */
  128.     wdw_clrl(lrow,TWcol(lcol));        /* clear rest of line    */
  129.     return(ptr);                /* ptr to end line lf    */
  130. }
  131.  
  132. /*
  133.     Function to rewrite the current line
  134. */
  135. rewrite_line(whole_line)
  136. int    whole_line;
  137. {
  138.     unsigned char    *ptr;
  139.     int        botW;
  140.  
  141.     hilicheck(1);                    /* set test function */
  142.     setwptr(TMP1);                    /* save current_char */
  143.     if (!whole_line && lcol >= wdw_cols - 15)    /* at 60th column... */
  144.         whole_line = true;            /* check word wrap   */
  145.     if (whole_line)
  146.         backup(lcol = 0);            /* to start of line  */
  147.     wwon    = false;
  148.     cur_atr = 0;
  149.     lrow    = current.row;
  150.     ptr    = next_line(current_char);
  151.     if (cur_atr) vst_effects(shandle,0);
  152.     if (wwon) {
  153.         if (*ptr == lf) ++ptr;            /* never point to lf */
  154.         TWrewindow(ptr);
  155.         botW = (current.row >= (current.mrow - 1));
  156.         if (current_char <= wdw_ptr[TMP1]) {
  157.             TWhclip = 0;
  158.             review(botW ? 1:3), endreview(1);
  159.             TWsliderH();
  160.         }
  161.         else
  162.         if (botW)
  163.             review(0), endreview(1);
  164.         else {
  165.             setwptr(TMP3);
  166.             rescreen(current_char,current.row + 1);
  167.         }
  168.     }
  169.     TWrewindow(wdw_ptr[TMP1]);
  170. }
  171.  
  172. /*
  173.     Function to backup count lines, 0 => beginning of line
  174. */
  175. backup(count)
  176. unsigned count;
  177. {
  178.     unsigned char    *ptr;
  179.     unsigned    how_many;
  180.  
  181.     how_many = 0;
  182.     if (free_start > buf_start) {
  183.       ptr = free_start;
  184.       while (1) {
  185.         while ( ptr > buf_start ) {        /* to start of line  */
  186.             if (tagc(*(ptr-2)))
  187.                 ptr -= 2;
  188.             else
  189.             if (*(ptr-1) != lf)
  190.                 --ptr;
  191.             else    break;
  192.         }
  193.         if (!count-- || ptr <= buf_start)
  194.             break;
  195.         ++how_many; --ptr;
  196.       }
  197.       if (ptr != free_start) {
  198.         if (*ptr == lf) ++ptr;            /* never point to lf */
  199.         TWrewindow(ptr);
  200.       }
  201.     }
  202.     return(how_many);
  203. }
  204.  
  205. /*
  206.     Function to forward count lines, 0 => end of line
  207. */
  208. forup(count)
  209. unsigned count;
  210. {
  211.     unsigned char    *ptr;
  212.     unsigned    how_many;
  213.  
  214.     how_many = 0;
  215.     if (current_char < buf_end) {
  216.       ptr = current_char;
  217.       while (1) {
  218.         while (!lpend(ptr) && ptr < buf_end)    /* to end of line... */
  219.             ptr = skiptag(ptr);
  220.         if (!count-- || ptr >= buf_end)
  221.             break;
  222.         while (*ptr++ != lf);            /* skip over CR/LF   */
  223.         ++how_many;                /* to next line..... */
  224.         if (!count) break;
  225.       }
  226.       if (*ptr == cr) --ptr;            /* never point to cr */
  227.       TWrewindow(ptr);
  228.     }
  229.     return(how_many);
  230. }
  231.  
  232. rescreen(where,start_row)
  233. unsigned char    *where;
  234. int        start_row;
  235. {
  236.     backup(cur_atr = 0);                /* to start of line  */
  237.     for (lrow = start_row;lrow < current.mrow;++lrow) {
  238.       if (where >= free_start && where < current_char)
  239.         where = current_char;
  240.       lcol = 0;
  241.       if (    wdw_ptr[lrow + top_line] != where  ) {
  242.         wdw_ptr[lrow + top_line]  = where;
  243.         where = next_line(where);
  244.       }
  245.       else    where = (*scanline)(where);
  246.       if (*where == lf) ++where;            /* never point to lf */
  247.     }
  248.     if (cur_atr) vst_effects(shandle,0);
  249.     TWrewindow(wdw_ptr[bot_line()]);        /* reset all pters.. */
  250.     TWrewindow(wdw_ptr[TMP3]);
  251. }
  252.  
  253. new_screen()
  254. {
  255.     rescreen(wdw_ptr[TMP3],top_row);
  256. }
  257.  
  258. /*
  259.     Function to rewrite the entire screen
  260.     new_one:    0: rescreen as necessary
  261.             1: rescreen 3 line previous to the current position
  262.             2: force complete rescreen
  263.             3: rewrite the current window
  264. */
  265. review(new_one)
  266. int    new_one;
  267. {
  268.     int    i, last_line;
  269.     char    *np;
  270.  
  271.     setwptr(TMP2);                    /* save current_char */
  272.     backup(VSchk = 0);                /* to start of line  */
  273.     if (new_one) {                    /* if forced mode... */
  274.       if (new_one == 3) {                /* current screen... */
  275.         if (current.row < current.mrow)        /* cursor in screen  */
  276.             TWrewindow(wdw_ptr[top_line]);    /* reset ptrs to top */
  277.         else    new_one = 1;            /* else force mode 1 */
  278.       }
  279.       if (new_one == 1)                /* or up 3 lines...  */
  280.         backup(3);                /* readjust all ptrs */
  281.       for (i = top_line;i < wdw_tags;)
  282.         wdw_ptr[i++] = (char *)0;        /* insure rewrite... */
  283.       setwptr(TMP3);
  284.       if (new_one < 3) VSchk = 1;
  285.     }
  286.     else {                        /* check what needed */
  287.       for (i = bot_line();i > top_line;--i)        /* find last line... */
  288.         if (wdw_ptr[i]) break;
  289.       last_line = i;
  290.       if (current_char < wdw_ptr[top_line]) {    /* before top row... */
  291.         np = toeofline(current_char);
  292.         if ((np + 1) == wdw_ptr[top_line]) {
  293.           for (i = bot_line();i > top_line;--i)
  294.             wdw_ptr[i] = wdw_ptr[i-1];
  295.           wdw_scroll(0);            /* scroll down...    */
  296.         }
  297.         else    backup(3);
  298.         setwptr(TMP3);
  299.         VSchk = 1;
  300.       }
  301.       else {                    /* after last row... */
  302.         np = toeofline(wdw_ptr[last_line]);
  303.         if (current_char >= (np + 1)) {
  304.           setwptr(TMP3);
  305.           TWrewindow(wdw_ptr[top_line]);
  306.           np = toeofline(wdw_ptr[last_line]);
  307.           if ((np + 1) == wdw_ptr[TMP3]) {
  308.             for (i       = top_line,
  309.              last_line = bot_line();
  310.              i < last_line;++i)
  311.             wdw_ptr[i] = wdw_ptr[i+1];
  312.             wdw_scroll(1);            /* scroll up...      */
  313.             wdw_ptr[TMP3] = wdw_ptr[top_line];
  314.           }
  315.           else {
  316.             TWrewindow(wdw_ptr[TMP3]);
  317.             backup(3);
  318.             setwptr(TMP3);
  319.           }
  320.           VSchk = 1;
  321.         }
  322.         else wdw_ptr[TMP3] = wdw_ptr[top_line];    /* simply redisplay  */
  323.       }
  324.     }
  325. }
  326.  
  327. endreview(mode)
  328. int    mode;
  329. {
  330.     if (mode) new_screen();
  331.     TWrewindow(wdw_ptr[TMP2]);
  332.     if (VSchk) TWsliderV();
  333. }
  334.  
  335. /*
  336.     Function to set the cursor positions
  337. */
  338. cursor()
  339. {
  340.     int        i, hmove, line;
  341.     unsigned char    *ptr, svlcol;
  342.  
  343.     setwptr(TMP2);                    /* save current_char */
  344.     line = cur_line();
  345.     if (!wdw_ptr[line]          ||
  346.         current_char <  wdw_ptr[line] ||
  347.         current_char >= wdw_ptr[line+1]) {        /* current ptr moved */
  348.       for (    i    = top_line,
  349.         line    = bot_line();
  350.         i <= line;++i )                /* find new row...   */
  351.         if (wdw_ptr[i] >= current_char) break;
  352.       if (i != top_line) {
  353.         if (wdw_ptr[i] == current_char) {        /* ptr at start line */
  354.         TWrewindow(wdw_ptr[i-1]);        /* backup one line.. */
  355.         ptr = toeofline(current_char);
  356.         if (ptr >= buf_end)            /* check end of file */
  357.             current.row = i - (top_line+1);    /* yes set row here  */
  358.         else    current.row = i - top_line;
  359.         TWrewindow(wdw_ptr[TMP2]);        /* back to orig. ptr */
  360.         }
  361.         else current.row = i - (top_line+1);    /* at previous line  */
  362.       }
  363.       else    current.row = top_row;
  364.     }
  365.     TWrewindow(wdw_ptr[cur_line()]);    /* to start of current line  */
  366.     ptr    = current_char;
  367.     lcol    = 0;
  368.     while (ptr < wdw_ptr[TMP2]) {
  369.         ptr = skiptag(ptr);
  370.         ++lcol;
  371.     }
  372.     hmove = lcol - (current.mcol / 2);
  373.     if (lcol < TWhclip) {
  374.         TWhclip = (hmove > 0) ? hmove:0;
  375.         hmove = 1;
  376.     }
  377.     else
  378.     if (lcol > (TWhclip + current.mcol) && current.mcol < wdw_cols) {
  379.         TWhclip = hmove;
  380.         hmove = 1;
  381.     }
  382.     else    hmove = 0;
  383.     TWrewindow(wdw_ptr[TMP2]);
  384.     if (hmove) {
  385.         svlcol = lcol;
  386.         Creview(3);
  387.         TWsliderH();
  388.         lcol = svlcol;
  389.     }
  390.     current.col = lcol - TWhclip;
  391.     TWcursor();
  392. }
  393.  
  394. TWclipdraw(func,arg)
  395. int    (*func)(), arg;
  396. {
  397.     gsx_moff();
  398.     clrcursor();
  399.     set_clip(1,&twork);
  400.     (*func)(arg);
  401.     set_clip(0,&twork);
  402.     gsx_mon();
  403. }
  404.  
  405. Creview(mode)
  406. int    mode;
  407. {
  408.     hilicheck(0);
  409.     TWclipdraw(review,mode), TWclipdraw(endreview,1);
  410. }
  411.  
  412. /*
  413.     Function to update if needed new window
  414. */
  415. nscr(mode)
  416. int    mode;
  417. {
  418.     Creview(mode); cursor();
  419. }
  420.  
  421. rwnscr(ptr,mode)
  422. char    *ptr;
  423. int    mode;
  424. {
  425.     TWrewindow(ptr); nscr(mode);
  426. }
  427.  
  428. /*
  429.     Function to rewrite the current line and update
  430.     the whole window if needed
  431. */
  432. nsline()
  433. {
  434.     nscr(0);
  435.     TWclipdraw(rewrite_line,1);
  436.     cursor();
  437. }
  438.  
  439. /*
  440.     Function to add CR-LF to free_start area
  441. */
  442. addcrlf()
  443. {
  444.     *free_start++ = cr; *free_start++ = lf;
  445. }
  446.  
  447. /*
  448.     Function to clear window line at row/column positions
  449. */
  450. wdw_clrl(row,col)
  451. {
  452.     GRECT    box;
  453.     long    scrmfdb = 0L;            /* screen MFDB address    */
  454.  
  455.     box.g_x    = xcrs(col);
  456.     if (box.g_x < twork.g_x || box.g_x >= (twork.g_x + twork.g_w))
  457.         return;
  458.     box.g_y    = ycrs(row);
  459.     box.g_w    = (twork.g_x + twork.g_w) - box.g_x;
  460.     box.g_h    = gl_hchar;
  461.     rast_op(0,&box,&scrmfdb,&box,&scrmfdb);
  462. }
  463.  
  464. /*
  465.     Function to output a line to Text window
  466. */
  467. wdw_line(row,col)
  468. int    row, col;
  469. {
  470.     if (*TWLnbuf)
  471.         v_gtext(shandle,xcrs(col),ycrs(row),TWLnbuf);
  472. }
  473.  
  474. /*
  475.     Function to output a line ending code to Text window
  476.     and clear the rest of the line at current cursor positions.
  477. */
  478. wdw_eol(eolc)
  479. char    eolc;
  480. {
  481.     TWLnbuf[0] = ctvdc(eolc), TWLnbuf[1] = 0;
  482.     wdw_line(current.row,current.col);
  483.     wdw_clrl(current.row,current.col + 1);
  484. }
  485.  
  486. /*
  487.     Function to check if Text window is topped.
  488. */
  489. check_TWtop()
  490. {
  491.     int    thandle, dummy;
  492.  
  493.     wind_get(0,WF_TOP,&thandle,&dummy,&dummy,&dummy);
  494.     return(thandle == txt_handle);
  495. }
  496.  
  497. /*
  498.     Function to update Text window Name field
  499. */
  500. TW_name(name)
  501. char    *name;
  502. {
  503.     strcpy(TWNmbuf,TWmesg[0]);
  504.     strcat(TWNmbuf,name);
  505.     wind_set(txt_handle,WF_NAME,TWNmbuf,0,0);
  506.     TWhclip = 0;
  507.     if (name != nuls)
  508.         TWrfmod = 2;
  509.     else {    TWVSLpos  = 0;
  510.         TWVSLsize = 1000;
  511.         TWslider_chk();
  512.     }
  513. }
  514.  
  515. /*
  516.     Function to update/clear Text window Info field
  517. */
  518. TW_info(msgno)
  519. int    msgno;
  520. {
  521.     char    *msgp;
  522.  
  523.     if (msgno == -1)                /* clear mode    */
  524.         msgp = nuls;
  525.     else    rsrc_gaddr(R_STRING,msgno,&msgp);
  526.     strcpy(TWIfbuf,TWmesg[1]);
  527.     strcat(TWIfbuf,msgp);
  528.     wind_set(txt_handle,WF_INFO,TWIfbuf,0,0);
  529. }
  530.  
  531. /*
  532.     Function to wait for one or both Window redraw
  533. */
  534. BWredraw()
  535. {
  536.     int    ret;            /* dummy variable    */
  537.     int    event;            /* which event returned    */
  538.     int    rdw = 0;        /* window redrawn flag    */
  539.  
  540.     do {
  541.       wind_update(false);
  542.       event = evnt_multi(MU_MESAG | MU_TIMER,
  543.             0,0,0,
  544.             0,0,0,0,0,
  545.             0,0,0,0,0,
  546.             msg_buff,
  547.             500,0,            /* timer = 0.5s    */
  548.             &ret,&ret,&ret,&ret,&ret,&ret);
  549.       wind_update(true);
  550.       if ((event & MU_TIMER) && rdw)    /* force out    */
  551.         break;
  552.       if ((event & MU_MESAG) && msg_buff[0] == WM_REDRAW) {
  553.         do_redraw(msg_buff);
  554.         ++rdw;
  555.       }
  556.     } while (rdw < 2);
  557. }
  558.  
  559. word_wrap(ptr,wcol,oneline)
  560. unsigned char    *ptr, wcol;
  561. int        oneline;
  562. {
  563.     unsigned char    *lptr;
  564.  
  565.     wdw_ptr[WWRP] = ptr;
  566.     while (ptr < wdw_ptr[TMP4]) {
  567.       if (wcol >= wdw_cols) {
  568.         if (*ptr == cr)
  569.             goto hitcr;
  570.         else
  571.         if (*ptr == ' ') {
  572.           if (*(ptr+1) == cr)
  573.             goto nextc;
  574.           else    ++ptr;
  575.         }
  576.         else {
  577.           TWrewindow(wdw_ptr[WWRP]);
  578.           for ( lptr = ptr-1;
  579.             lptr > wdw_ptr[WWRP]    &&
  580.             !tagc(*(lptr-1))    &&
  581.             *lptr != ' ';
  582.             --lptr );
  583.           if (lptr > wdw_ptr[WWRP])
  584.             ptr = ++lptr;
  585.         }
  586.         TWrewindow(ptr);
  587.         addcrlf();
  588.         ptr    = current_char;
  589.         wwon    = true;
  590.         goto check;
  591.       }
  592.       while (*ptr == cr) {
  593.         if (    ptr > current_char &&
  594.             !tagc(*(ptr-2))    &&
  595.             allend(*(ptr-1))    )
  596.             goto hitcr;
  597.         TWrewindow(ptr);
  598.         ptr    = (current_char += 2);
  599.         TWrewindow(ptr);
  600.         wwon    = true;
  601.       }
  602.       if (*ptr != cr) {
  603. nextc:        ptr = skiptag(ptr);
  604.         ++wcol;
  605.       }
  606.       else {
  607. hitcr:        ptr += 2;
  608. check:        if (oneline) return;
  609.         wdw_ptr[WWRP] = ptr;
  610.         wcol = 0;
  611.       }
  612.     }
  613. }
  614.  
  615. TWcursor()
  616. {
  617.     gsx_moff();
  618.     setcursor(0);
  619.     gsx_mon();
  620. }
  621.  
  622. static    TWcol(col)
  623. int    col;
  624. {
  625.     return((col >= TWhclip) ? (col - TWhclip):0);
  626. }
  627.  
  628. /*
  629.     mode 0 ... Normal (no hilight) mode
  630. */
  631. static    tmod0(ptr)
  632. char    *ptr;
  633. {
  634.     return(0);
  635. }
  636.  
  637. /*
  638.     mode 1 ... New position below marker
  639. */
  640. static    tmod1(ptr)
  641. char    *ptr;
  642. {
  643.     if (ptr >= wdw_ptr[HMRK] && ptr < wdw_ptr[cMrk])
  644.         return(9);
  645.     else    return(0);
  646. }
  647.  
  648. /*
  649.     mode 2 ... New position above marker
  650. */
  651. static    tmod2(ptr)
  652. char    *ptr;
  653. {
  654.     if (ptr == wdw_ptr[HMRK])
  655.         return(10);
  656.     else
  657.     if (ptr >= wdw_ptr[cMrk] && ptr < wdw_ptr[HMRK])
  658.         return(9);
  659.     else    return(0);
  660. }
  661.  
  662. /*
  663.     Function to check high light defined text mode
  664.     when in Delete/Buffer/Tag commands
  665. */
  666. hilicheck(mode)
  667. int    mode;
  668. {
  669.     if (!mrkfctN) {
  670.         attrtest = tmod0;
  671.         scanline = toeofline;
  672.     }
  673.     else {
  674.       cMrk = mode ? TMP1:TMP2;
  675.       if (current_char > wdw_ptr[HMRK])    /* down/right    */
  676.         attrtest = tmod1;
  677.       else    attrtest = tmod2;        /* up/left    */
  678.         scanline = out_line;
  679.     }
  680. }
  681.  
  682. static    hili_mark(curc)
  683. char    curc;
  684. {
  685.     TWLnbuf[0] = ctvdc(curc), TWLnbuf[1] = 0;
  686.     vst_effects(shandle,10);
  687.     wdw_line(current.row,current.col);
  688.     vst_effects(shandle,0);
  689. }
  690.  
  691. wdw_mark()
  692. {
  693.     TWclipdraw(hili_mark,*current_char);
  694.     TWcursor();
  695. }
  696.  
  697. nchartoEline()
  698. {
  699.     int    nchar;                /* # of chars to eoline */
  700.     char    *ptr;
  701.  
  702.     for (    ptr = current_char, nchar = 0;
  703.         ptr < buf_end && *(ptr+1) != cr;
  704.         ptr = skiptag(ptr), ++nchar    );
  705.     return(nchar);
  706. }
  707.  
  708. /*
  709.     Routine to move the text pointer closest to the
  710.     current cursor position
  711. */
  712. movetoCcol()
  713. {
  714.     unsigned char    *ptr;
  715.  
  716.     ptr    = current_char;
  717.     lcol    = 0;
  718.     while (!lpend(ptr) && ptr < buf_end) {        /* to end of line... */
  719.         if (lcol >= TWhclip && (lcol - TWhclip) >= current.col)
  720.             break;
  721.         ptr = skiptag(ptr);
  722.         ++lcol;
  723.     }
  724.     if (*ptr == cr) --ptr;                /* never point to cr */
  725.     TWrewindow(ptr);
  726. }
  727.  
  728. ckTWsliderV()
  729. {
  730.     if (!VSchk) TWsliderV();
  731. }
  732.